/*
 * EntityPanel.java
 *
 * Created on May 20, 2011, 5:01:43 PM
 */
package pt.utl.ist.isr.livetrack.tracker.gui;

import java.awt.Dimension;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import pt.utl.ist.isr.livetrack.tracker.mht.EntityInFact;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class EntityPanel extends javax.swing.JPanel {

    private EntityInFact fact;

    /** Creates new form EntityPanel */
    public EntityPanel(EntityInFact<BufferedImage> fact) {
        initComponents();
        this.fact = fact;
//        infoLabel.setText("Entity " + fact.getEntity().getId() + " IN " + fact.getZone().toString());
//        infoLabel.setFont(Font.decode("Arial-18"));
        String s = "";
        s += "Entity " + fact.getEntity().getId() + " IN " + fact.getZone().toString() + "\n";
        s += "Last detection at: " + fact.getLastDetection() + "\n";
        s += "Features: ";
        for (double d : fact.getFeatures()) {
            s += (((int) (d * 1000)) / 1000.0) + ", ";
        }
        s += "\n";
        jTextArea1.setText(s);
        Image last = fact.getEntityInformation();
        if (last != null) {
            imageLabel.setIcon(new ImageIcon(last.getScaledInstance((last.getWidth(null) * 150) / last.getHeight(null), 150, Image.SCALE_FAST)));
        }
        setMinimumSize(new Dimension((int) getMinimumSize().getWidth(), 160));
        setSize(getWidth(), 160);
    }

    public EntityInFact getEntityInFact() {
        return fact;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        imageLabel = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        imageLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(imageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel imageLabel;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration//GEN-END:variables
}
